﻿using Basic.HrGatewayModular.Interface;
using Basic.HrGatewayModular.Model.Msg;
using Basic.HrRemoteModel.Msg;
using Basic.HrRemoteModel.Msg.Model;
using WeDonekRpc.Client;
using WeDonekRpc.HttpApiGateway.Model;

namespace Basic.HrGatewayModular.Services
{
    internal class MsgService : IMsgService
    {
        public Dictionary<string, int> GetTotal ( MsgGetUI arg, long empId )
        {
            return new GetUserMsgTotal
            {
                GetArg = new MsgGetArg
                {
                    EmpId = empId,
                    IsRead = arg.IsRead,
                    MsgClassify = arg.MsgClassify,
                    MsgType = arg.MsgType,
                    Tag = arg.Tag,
                    MsgStatus = arg.MsgStatus,
                }
            }.Send();
        }

        public PagingResult<MsgDatum> Query ( PagingParam<MsgQueryUI> param, long empId )
        {
            return new QueryMsg
            {
                Size = param.Size,
                SortName = param.SortName,
                Index = param.Index,
                IsDesc = param.IsDesc,
                Query = new MsgQuery
                {
                    EmpId = empId,
                    IsRead = param.Query.IsRead,
                    MsgClassify = param.Query.MsgClassify,
                    MsgStatus = param.Query.MsgStatus,
                    MsgType = param.Query.MsgType,
                    Priority = param.Query.Priority,
                    Tag = param.Query.Tag,
                    IsTimeOut = param.Query.IsTimeOut,
                    AppId = param.Query.AppId,
                    Begin = param.Query.Begin,
                    End = param.Query.End,
                    QueryKey = param.Query.QueryKey
                },
                NextId = param.NextId,
            }.Send();
        }

        public void SetAlreadyRead ( long id )
        {
            new SetMsgRead
            {
                Id = id
            }.Send();
        }

        public void SetAlreadyRead ( long[] ids )
        {
            new SetBatchRead
            {
                Ids = ids
            }.Send();
        }


    }
}
